package com.cloud.hystrix;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author canger
 * @Deseription
 * @create 2018/9/26 14:54
 **/
@Service
public class ConsumerService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "fallback")
    public String consumer(){

        return restTemplate.getForObject("http://eureka-client/dc",String.class);

    }
    public String fallback(){
        return "fallback";
    }

}
